/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#define DirectorH(className, humanReadableName)\
	public:\
		const char* directorName() {return #humanReadableName ;}\
		IDirector* instance() {return new className();}\
		HObjectH(className)

#define DirectorCPP(className)\
	HObjectCPP(className)
	//int className ## ::_director_id = DirectorIndex::registerDirector<className>();\


#include "Hogshead.Common.h"
#include "IComponent.h"
#include "../DataStructures/ParameterField.h"

namespace Hogshead
{
	namespace Core
	{
		class IComponent;
		class Scene;
		class IMessage;

		class IDirector : public IHObject
		{
		public:
			IDirector();
			virtual ~IDirector(){}
			// add a component to receive messages sent by this director
			virtual void registerComponent(IComponent* in_component);
			// remove a component for message receiving
			virtual void unregisterComponent(IComponent* in_component);
			// register a director to receive messages 
			virtual void registerDirector(IDirector* in_director);

			Scene* getScene();
			void setScene(Scene* in_scene);

			// called per round
			virtual void update(const GameTimer& in_gt);
			// called per draw round
			virtual void draw();

			// called when we receive a message
			//virtual void message( const IMessage* in_message);

			// read in xml
			virtual IDirector* readXML(const String& in_xml);
			// called afer loading from xml
			virtual void initialize();
			
			virtual const char* directorName() = 0;
			virtual IDirector* instance() = 0;


		protected:
			Scene* _parent_scene;

			ArrayList<IComponent*> _registered_components;
			Vector<IDirector*> _registered_directors;
			ParameterField _pf;
		};
	}
}